using System;
using System.Collections.Specialized;
using System.Net;
using System.Text;
using System.IO;

/// <summary>
/// Summary description for Class1
/// </summary>
public class HttpRequestResponse
{
    private string URI;
    private string Request;
    private string UserName;
    private string UserPwd;
    private string ProxyServer;
    private int ProxyPort;
    private string RequestMethod = "GET";

    public HttpRequestResponse(string pRequest, string pURI)
	{
		//
		// TODO: Add constructor logic here
		//
        Request = pRequest;
        URI = pURI;
        UserName = "TV-PCSUITE";
        UserPwd = "TV2014-PCSUITE";
	}

    public string HTTP_USER_NAME
    {
        get
        {
            return UserName;
        }
        set
        {
            UserName = value;
        }
    }

    public string HTTP_USER_PASSWORD
    {
        get
        {
            return UserPwd;
        }
        set
        {
            UserPwd = value;
        }
    }

    public string PROXY_SERVER
    {
        get
        {
            return ProxyServer;
        }
        set
        {
            ProxyServer = value;
        }
    }

    public int PROXY_PORT
    {
        get
        {
            return ProxyPort;
        }
        set
        {
            ProxyPort = value;
        }
    }

    public string SendRequest()
    {
        string FinalResponse = "";
        string Cookie = "";
        HttpBaseClass BaseHttp = new HttpBaseClass(UserName, UserPwd, ProxyServer, ProxyPort, Request);
        try
        {
            RequestMethod = "POST";
            FinalResponse = BaseHttp.GetFinalResponse(URI, Cookie, RequestMethod, true);
        }
        catch (WebException ex)
        {
            Console.WriteLine("SendRequest web exception : {0}", ex.Message);
        }
        catch (System.Exception ex)
        {
            Console.WriteLine("SendRequest exception : {0}", ex.Message);
        }
        finally
        {
            BaseHttp = null;
        }
        
        return FinalResponse;
    }

    private WebException CatchHttpException(string ErrMsg)
    {
        ErrMsg = "Error During Wen Interface. Error is:" + ErrMsg;
        return new WebException(ErrMsg);
    }
}
